package com.tinklabs.demo.adapter.decoration;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.tinklabs.demo.utils.ScreenUtils;


/**
 * Created by Jennifer on 2018/3/18.
 */
public class LinearSpaceItemDecoration extends RecyclerView.ItemDecoration {

    private int leftSpace;
    private int rightSpace;
    private int topSpace;
    private int bottomSpace;

    public LinearSpaceItemDecoration(Context context,int topSpace, int bottomSpace) {
        this(context, 0, 0, topSpace, bottomSpace);
    }

    public LinearSpaceItemDecoration(Context context, int leftSpace, int rightSpace, int topSpace, int bottomSpace) {
        this.leftSpace = ScreenUtils.dp2px(context, leftSpace);
        this.rightSpace = ScreenUtils.dp2px(context, rightSpace);
        this.bottomSpace = ScreenUtils.dp2px(context, bottomSpace);
        this.topSpace = ScreenUtils.dp2px(context, topSpace);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.set(leftSpace, topSpace, rightSpace, bottomSpace);

    }


}